package util

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
	"math/rand"
	"strings"
	"time"
)

func GenerateSn() string {
	code := time.Now().Format("20060102150405")
	return code + fmt.Sprintf("%03d", rand.Intn(1000))
}

func MD5To16(str string) string {
	hash := md5.Sum([]byte(str))
	data := hex.EncodeToString(hash[:])
	result := data[8:24]
	strUpper := strings.ToUpper(result)
	return strUpper
}
